<?php


namespace App\Http\Controllers\Api;


use App\Extends\Helpers\Result;
use Illuminate\Routing\Controller;
use Elasticsearch\ClientBuilder;

class TestController extends Controller
{

    public function index(){
        $this::es();
        return Result::success('asdasdaa');
    }

    public function es() {

        $hosts = [
            'elasticsearch:9200',         // IP + Port
            'elasticsearch',              // Just IP
            'elasticsearch:9200', // Domain + Port
            'elasticsearch',     // Just Domain
            'http://elasticsearch',        // SSL to localhost
            'https://elasticsearch:9200'  // SSL to IP + Port
        ];
        $client = ClientBuilder::create()->setHosts($hosts)->build();            // Instantiate a new ClientBuilder  // Set the hosts


        $params = [
            'index' => 'test_data',
            'type' => 'users',
            'id' => 100027,
            'client' => ['ignore' => 404]
        ];
        printf(json_encode($client->get($params)));

//        return Result::success($client->get($params));
    }
}
